Grails + Acegi + IntelliJ
- Create new Grails application project.
- Create a new domain class using ‘grails create-domain-class domain’ and make sure the name does not have ‘order’ in it. For some reason, the IntelliJ generated domain is not recognized as a valid domain class by grails.
- Added some fields to the domain class
- Generate the Controllerclass using IntelliJ (grails create-controller script is not good enough)
- Modified the ‘def index = …’ into ‘def scaffold = …’
- run-app
- grails install-plugin acegi
- grails create-auth-domains User Role Requestmap
- grails generate-manager
- grails generate-registration
- grails run-app
- Create userroles : ROLEADMIN and ROLEUSER
- Create user: admin with ROLEADMIN and user with ROLEUSER
- Create mapping: i.e. /Inventory/** for ROLE_ADMIN
- grails run-app
To enable HTTPS: Look here http://www.stainlesscode.com/site/comments/acegi_spring_security_https_and_grails/ basically:
-
grails install-templates, ( the following code is generated from http://www.simplebits.com )
<filter> <filter-name>Acegi Channel Processing Filter</filter-name> <filter-class>org.springframework.security.util.FilterToBeanProxy</filter-class> <init-param> <param-name>targetClass</param-name> <param-value>org.springframework.security.securechannel.ChannelProcessingFilter</param-value> </init-param> </filter> <filter-mapping> <filter-name>Acegi Channel Processing Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
-
Navigate to the src/templates/war and add the filter to the web.xml template there:- This following code should be put into yout grails-app/conf/spring/resource.groovy file (the entire file is reproduced here):
import org.springframework.security.securechannel.ChannelProcessingFilter import org.springframework.security.securechannel.ChannelDecisionManagerImpl import org.springframework.security.securechannel.SecureChannelProcessor import org.springframework.security.securechannel.InsecureChannelProcessor // Place your Spring DSL code here beans = { secureChannelProcessor(SecureChannelProcessor) insecureChannelProcessor(InsecureChannelProcessor) channelDecisionManager(ChannelDecisionManagerImpl) { channelProcessors = [secureChannelProcessor, insecureChannelProcessor] } channelProcessingFilter(ChannelProcessingFilter) { channelDecisionManager=channelDecisionManager filterInvocationDefinitionSource=''' CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON PATTERN_TYPE_APACHE_ANT /**=REQUIRES_SECURE_CHANNEL ''' } }
- grails run-app —https
Links: http://luxsci.com/blog/256-bit-aes-encryption-for-ssl-and-tls-maximal-security.html
Subscribe to Lydon's blog
Get the latest posts delivered right to your inbox